#include<bits/stdc++.h>
using namespace std;
#define maxsize 10

typedef struct Node
{
    int data;
    struct Node* next;
}QNode;

typedef struct
{
    QNode* front;
    QNode* rear;
}linkqueue;

void initLQ(linkqueue* q)
{
    q->front = q->rear = new QNode;
    q->front->next=NULL;
}

void pushLQ(linkqueue* q,int data)
{
    QNode* p;
    p = new QNode;
    p->data = data;
    p->next = NULL;
    q->rear->next = p;
    q->rear = p;
}

void popLQ(linkqueue* q,int* data)
{
    QNode* temp;
    if(q->front->next==NULL)
    {
        printf("队列为空!");
        return;
    }
    temp = q->front->next;
    if(q->front->next = q->rear)
    {
        q->front = q->rear = NULL;
    }
    else
    {
        q->front->next = temp->next;
    }
    *data = temp->data;
    free(temp);
}

void printLQ(linkqueue* q)
{
    if(q->front==q->rear)
    {
        printf("队列为空队列");
        return;
    }
    QNode* p;
    p = q->front->next;
    while(p)
    {
        printf("%d ",p->data);
        p = p->next;
    }
}
int main()
{
    linkqueue q;
    initLQ(&q);
    pushLQ(&q,1);
    pushLQ(&q,2);
    printLQ(&q);
}